package com.my.exceptions;

import java.io.FileReader;
import java.io.IOException;

/**
 * @author: marshal
 * @date: 2023-03-15 10:50
 */
public class ExceptionTest {


    public static void main(String[] args) {
        System.out.println(runtimeExceptions(10, 0));
    }

    private static void checkedException(String filepath) {
        try (FileReader fr = new FileReader(filepath)) {
            int read = fr.read();
        } catch (IOException e) {
            System.out.println("异常信息： " + e.getMessage());
        }
    }

    private static int runtimeExceptions(int a, int b) {
        int r = -1;
        try {
            r = a / b;
            System.out.println("发生异常，还会执行吗？");
            return r;
        } catch (ArithmeticException e) {
            System.out.println("异常信息： " + e.getMessage());
            e.printStackTrace();
        } finally {
            System.out.println("finally");
        }
        return r;
    }
}
